package com.dudu.dao;

import java.sql.Connection;
import java.util.List;

import net.sf.json.JSONObject;
import core.CoreDao;
import core.db.DBConnectionUtil;

public class RecordInfoDao {

	/**
	 * 录音文件信息表插入数据
	 * @param dao
	 * @param meetId
	 * @param sessionId
	 * @param abilityType
	 * @param sendFileUrl
	 * @return
	 */
	public int insert(CoreDao dao, String sessionId,
			String abilityType, String sendFileUrl) {
		Connection con = null;
		int result = -1;
		try {
			con = DBConnectionUtil.getDBConnection("emate1");
			StringBuffer sql = new StringBuffer(
					"INSERT INTO t_record_info(session_id, ability_type, sendfile_url, create_time, send_time,"
							+ "status, callback_status)");
			sql.append("VALUES(?, ?, ? ,sysdate(),sysdate(), 0, 0)");
			List<JSONObject> list = dao.serviceJsonSql(con, sql.toString(),
					new Object[] {
						sessionId, abilityType, sendFileUrl,
					});
			JSONObject obj = list.get(0);
			result = obj.optInt("result");
		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			DBConnectionUtil.close(null, null, con);
		}
		return result;
	}

}
